const redis = require('./redis');

const set = (key, value, ex) => {
    return new Promise((resolve, reject) => {
        redis.set(key, value, 'EX', ex, (err, resp) => {
            if (err) reject(err);
            else resolve(resp);
        });
    });
};

const get = (key) => {
    return new Promise((resolve, reject) => {
        redis.get(key, (err, resp) => {
            if (err) reject(err);
            else resolve(resp);
        });
    });
};

const del = (key) => {
    return new Promise((resolve, reject) => {
        redis.del(key, (err, resp) => {
            if (err) reject(err);
            else resolve(resp);
        });
    });
};

module.exports = {
    set,
    get,
    del
}
